<?php 
## include required files
/*******************************/
require_once '../model/moduleuser.php';
/*******************************/


## check is another acessing this module
if($_SESSION['admin_id'] != 2) {
	## techmodi admin user
	header('location:'.SITE_URL.'/admin/home.php');	
	exit;
}

## Create Objects
/*******************************/
$moduleObj = new Model_ModuleUser();
/*******************************/
if(isset($_POST['update'])) {
	//echo "<pre>"; print_r($_POST);exit;
	$ids = implode(",", $_POST['checkall']);
	$moduleObj->updateModulesStatusIn($ids);
	$moduleObj->updateModulesStatusNotIn($ids);
	$_SESSION['msg']="<div class='success_msg'><span>Modules settings updated successfully</span></div>";
	header('location:'.SITE_URL.'/admin/home.php?q=settings');
	exit;
	
}

$modules = $moduleObj->getAllMasterModules();
$smarty->assign('modules', $modules);

## Assign success or error msg to smarty variable and unset session variable
if(trim($_SESSION['msg']) != '') {
	$smarty->assign('msg', $_SESSION['msg']);
	unset($_SESSION['msg']);
}

## Unset all the objects created which are on this page
unset($adminObj);

$smarty->display(TEMPLATEDIR_ADMIN. 'settings/settings.tpl');
unset($smarty);
?>